/* Flexbox三栏布局与3.html风格样式 */
body {
    background: linear-gradient(45deg, #1a237e, #311b92, #4a148c);
    color: #ffffff;
    min-height: 100vh;
    padding: 0;
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
/* 父容器宽度 */
.container {
    display: flex;
    flex-direction: row;
    gap: 24px;
    max-width: 2000px;
    height:auto;
    margin: 0 auto;
    padding: 24px 0;
}

.animation-section {
    flex: 1.2 1 0;
    min-width: 320px;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    background: rgba(15, 20, 60, 0.75);
    border-radius: 18px;
    padding: 25px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(80, 120, 255, 0.4);
    margin-bottom: 0;
}

.animation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(79, 195, 247, 0.3);
}

.animation-title {
    font-size: 1.4rem;
    font-weight: 600;
    color: #4fc3f7;
    text-shadow: 0 0 10px rgba(79, 195, 247, 0.5);
}

.animation-status {
    display: flex;
    align-items: center;
}

.run-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    letter-spacing: 0.5px;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    transition: all 0.3s ease;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(255, 255, 255, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
}

.run-status.not-running {
    background: linear-gradient(135deg, rgba(244, 67, 54, 0.1), rgba(244, 67, 54, 0.2));
    border: 1px solid rgba(244, 67, 54, 0.3);
}

.run-status.not-running .status-dot {
    background-color: #f44336;
    box-shadow: 0 0 8px #f44336;
    animation: pulse-red 1.5s infinite;
}

@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(244, 67, 54, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(244, 67, 54, 0); }
    100% { box-shadow: 0 0 0 0 rgba(244, 67, 54, 0); }
}

.run-status.not-running .status-text {
    color: #f44336;
    text-shadow: 0 0 5px rgba(244, 67, 54, 0.3);
}

.run-status.running {
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.1), rgba(76, 175, 80, 0.2));
    border: 1px solid rgba(76, 175, 80, 0.3);
}

.run-status.running .status-dot {
    background-color: #4caf50;
    box-shadow: 0 0 8px #4caf50;
    animation: pulse-green 1.5s infinite;
}

@keyframes pulse-green {
    0% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(76, 175, 80, 0); }
    100% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0); }
}

.run-status.running .status-text {
    color: #4caf50;
    text-shadow: 0 0 5px rgba(76, 175, 80, 0.3);
}

.status-indicator {
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    display: inline-block;
    background: rgba(244, 67, 54, 0.15);
    color: #f44336;
    border: 1px solid rgba(244, 67, 54, 0.3);
    box-shadow: 0 0 10px rgba(244, 67, 54, 0.2);
}

.status-indicator.running {
    background: rgba(76, 175, 80, 0.15) !important;
    color: #4caf50 !important;
    border: 1px solid rgba(76, 175, 80, 0.3) !important;
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.2) !important;
}

.status-indicator.not-running {
    background: rgba(244, 67, 54, 0.15) !important;
    color: #f44336 !important;
    border: 1px solid rgba(244, 67, 54, 0.3) !important;
    box-shadow: 0 0 10px rgba(244, 67, 54, 0.2) !important;
}

.canvas-container {
    position: relative;
    background: linear-gradient(160deg, #0d1021, #1c213d);
    border-radius: 15px;
    height: 700px; /* 小球动画高度 */
    overflow: hidden;
    box-shadow: 0 10px 35px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(100, 180, 255, 0.4);
    margin-bottom: 18px;
}

#pendulumCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

.timer-display {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0, 30, 60, 0.7);
    color: #80d6ff;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: bold;
    z-index: 10;
    box-shadow: 0 0 15px rgba(0, 20, 50, 0.7);
}

.visual-scale-info {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(0, 30, 60, 0.7);
    color: #ffcc80;
    padding: 8px 15px;
    border-radius: 8px;
    font-size: 0.9rem;
    z-index: 10;
}

.quick-instructions {
    margin-top: 15px;
    background: rgba(26, 32, 44, 0.6);
    border-radius: 12px;
    padding: 15px;
    border: 1px solid rgba(79, 195, 247, 0.2);
}
.instructions-title {
    font-size: 1rem;
    font-weight: 600;
    color: #4fc3f7;
    margin-bottom: 10px;
}
.instructions-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    font-size: 0.85rem;
    color: #cbd5e0;
}
.instruction-item {
    padding: 4px 8px;
    background: rgba(79, 195, 247, 0.1);
    border-radius: 6px;
    border-left: 3px solid #4fc3f7;
}

.controls-section {
    flex: 1 1 0;
    min-width: 320px;
    max-width: 2000px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    background: rgba(26, 32, 44, 0.8);
    border-radius: 16px;
    padding: 20px;
    border: 1px solid rgba(79, 195, 247, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    overflow-y: auto;
    overflow-x: hidden;/*左右滑动条删掉*/
    max-height: 200vh;
    margin-bottom: 48px;
}
/* 摄像头画面 */
.camera-container {
    width: 100%;
    max-width: 1600px;
    margin: 24px auto 18px auto;
    background: rgba(15, 20, 60, 0.75);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
}
#cameraWrapper {
    width: 100%;
    max-width: 400px;
    aspect-ratio: 9/16;
    position: relative;
    margin: 0 auto;
    background: #222;
    overflow: hidden;
}
#cameraFeed {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    border-radius: 8px;
    border: 2px solid #4fc3f7;
    background: #222;
}
#roiDiv {
    position: absolute;
    border: 2px dashed #ff9800;
    pointer-events: none;
    z-index: 10;
    display: none;
}
#syncStatus {
    margin: 8px auto 0 auto;
    text-align: center;
    color: #4fc3f7;
    font-size: 0.9rem;
    background: rgba(20,30,60,0.8);
    border-radius: 6px;
    max-width: 340px;
    padding: 6px 0;
}
.control-group {
    background: rgba(15, 23, 42, 0.6);
    border-radius: 12px;
    padding: 15px;
    border: 1px solid rgba(79, 195, 247, 0.2);
    margin-bottom: 10px;
}
.control-group h2 {
    font-size: 1.1rem;
    color: #4fc3f7;
    margin-bottom: 15px;
    text-align: center;
    font-weight: 600;
}
.slider-container {
    margin-bottom: 15px;
}
label {
    display: block;
    margin-bottom: 8px;
    color: #e2e8f0;
    font-size: 0.9rem;
    font-weight: 500;
}
.value-display {
    color: #4fc3f7;
    font-weight: 600;
    margin-left: 8px;
}
input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: rgba(79, 195, 247, 0.2);
    outline: none;
    -webkit-appearance: none;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #4fc3f7;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(79, 195, 247, 0.4);
}
.btn-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;/*导出数据字体居中*/
}
button {
    background: linear-gradient(45deg, #1976d2, #2196f3);
    color: white;
    border: none;
    padding: 10px 30px;
    /* 导出数据按钮 */
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: bold;
    letter-spacing: 0.8px;
    transition: all 0.3s ease;
    box-shadow: 0 6px 20px rgba(33, 150, 243, 0.4);
    margin-top: 8px;
    /* width: 100%; */
    min-width: 150px;
    position: relative;
    overflow: hidden;
}
button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(33, 150, 243, 0.6);
}
#exportBtn {/*自动导出按钮自适应*/
    min-width: 180px;
    padding: 14px 36px;
    font-size: 1.1rem;
    line-height: 1.8;
    height: auto;
    white-space: nowrap;
    box-sizing: border-box;
    display: inline-block;
}
.status-display {
    background: rgba(15, 23, 42, 0.6);
    border-radius: 8px;
    padding: 15px;
    border: 1px solid rgba(79, 195, 247, 0.2);
    margin-bottom: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.status-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.9rem;
    padding: 6px 10px;
    border-radius: 6px;
    background: rgba(15, 20, 30, 0.4);
    transition: all 0.3s ease;
}

.status-item:hover {
    background: rgba(15, 20, 30, 0.6);
}

.status-label {
    color: #94a3b8;
    font-weight: 500;
}

.status-value {
    color: #4fc3f7;
    font-weight: 600;
    text-shadow: 0 0 5px rgba(79, 195, 247, 0.3);
    transition: all 0.3s ease;
}

.status-value.running {
    color: #4caf50;
    text-shadow: 0 0 5px rgba(76, 175, 80, 0.3);
}

.status-value.waiting {
    color: #ff9800;
    text-shadow: 0 0 5px rgba(255, 152, 0, 0.3);
}

.status-value.error {
    color: #f44336;
    text-shadow: 0 0 5px rgba(244, 67, 54, 0.3);
}

.status-value.highlight {
    animation: highlight-pulse 2s infinite;
}

@keyframes highlight-pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}
.charts-section {
    flex: 1.2 1 0;
    min-width: 320px;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.chart-container {
    background: rgba(26, 32, 44, 0.8);
    border-radius: 16px;
    padding: 20px;
    border: 1px solid rgba(79, 195, 247, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    margin-bottom: 0;
}
.chart-title {
    font-size: 1.1rem;
    color: #4fc3f7;
    margin-bottom: 15px;
    text-align: center;
    font-weight: 600;
}
.chart-canvas {
    width: 100%;
    aspect-ratio: 4/3;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 12px;
    border: 1px solid rgba(79, 195, 247, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    padding: 0;
}

.chart-canvas canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
    border-radius: 12px;
    object-fit: contain;
}
.logs-section {
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex: 1;
}
.log-container {
    background: rgba(26, 32, 44, 0.8);
    border-radius: 16px;
    padding: 15px;
    border: 1px solid rgba(79, 195, 247, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    flex: 1;
    display: flex;
    flex-direction: column;
}
.log-title {
    font-size: 1rem;
    color: #4fc3f7;
    margin-bottom: 10px;
    font-weight: 600;
    text-align: center;
}
.log-content {
    flex: 1;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 8px;
    padding: 10px;
    border: 1px solid rgba(79, 195, 247, 0.2);
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    color: #cbd5e0;
    overflow-y: auto;
    max-height: 150px;
}
/* 响应式设计 */
@media (max-width: 1400px) {
    .container {
        gap: 15px;
        max-width: 1200px;
    }
    .animation-section, .charts-section {
        max-width: 400px;
    }
}
@media (max-width: 1100px) {
    .container {
        flex-direction: column;
        max-width: 900px;
    }
    .animation-section, .charts-section, .controls-section {
        max-width: 100%;
    }
}
@media (max-width: 768px) {
    .container {
        padding: 10px 0;
        gap: 8px;
    }
    .animation-section, .charts-section, .controls-section {
        padding: 10px;
    }
    .chart-canvas {
        height: 120px;
    }
}
#exportBtn {
    min-width: 180px;
    padding: 16px 36px;
    font-size: 1.2rem;
    line-height: 1.8;
    height: auto;
    white-space: nowrap;
    box-sizing: border-box;
    display: block; /* 或 flex/grid 容器下用 flex: 1 1 auto; */
    overflow: visible; /* 确保内容不会被裁剪 */
}

.run-status.not-running .status-text::before {
    content: "🔴 ";
}

.run-status.running .status-text::before {
    content: "🟢 ";
}

#startBtn, #resetBtn, #d0Btn, #d1Btn, #getPendulumLengthBtn {
    padding: 8px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    font-weight: 500;
    margin: 5px;
}

#startBtn {
    background-color: #4caf50;
    color: white;
}

#resetBtn {
    background-color: #2196f3;
    color: white;
}

#d0Btn, #d1Btn {
    background-color: #ff9800;
    color: white;
}

#getPendulumLengthBtn {
    background-color: #9c27b0;
    color: white;
}

#startBtn:hover, #resetBtn:hover, #d0Btn:hover, #d1Btn:hover, #getPendulumLengthBtn:hover {
    filter: brightness(1.1);
}

#startBtn:active, #resetBtn:active, #d0Btn:active, #d1Btn:active, #getPendulumLengthBtn:active {
    transform: scale(0.95);
}
